package com.jframe.app.action;

import java.util.ArrayList;
import java.util.List;

import com.jframe.app.model.Table;
import com.jframe.sys.controller.ExtendAction;
import com.jframe.sys.controller.utils.DicCache;
import com.jframe.sys.controller.utils.JsBuilder;
import com.jframe.sys.utils.JsonUtil;
import com.jframe.sys.webui.Columns;
import com.jframe.sys.webui.Editor;
import com.jframe.sys.webui.Grid;

public class TableAction extends ExtendAction {
	private static String ACTION="tableAction";
	private static String SERVICE = "tableService";
	private static Class<Table> CLAZZ = Table.class;

	public void list(){
		List<Columns> frozenColumns = new ArrayList<Columns>();// 固定列
		List<Columns> commonColumns = new ArrayList<Columns>();// 活动列		
		frozenColumns.add(new Columns("ck", "", 40, ""));
		commonColumns.add(new Columns("id", "编号", 100, ""));
		commonColumns.add(new Columns("tableName", "表名", 120, ""));
		commonColumns.add(new Columns("name", "显示名", 120, ""));
		commonColumns.add(new Columns("moduleId", "所属模块", 120, new Editor("combobox",true),DicCache.getComboboxJson("sm_sys_module")));
		commonColumns.add(new Columns("memo", "描述", 120, ""));
		commonColumns.add(new Columns("操作", 120, "operation"));
		Grid grid = new Grid();
		grid.setUrl(ACTION+".do?method=load");
		String js = JsBuilder.getJsStr(frozenColumns, commonColumns, grid);
		this.request.setAttribute("js", js);
		this.forward("/jframe/app/list/tableList.jsp");
	}

	public void load() {
		this.baseLoad(SERVICE, CLAZZ);
	}

	public void save() {
		this.baseSave(SERVICE, CLAZZ);
	}

	public void delete() {
		this.baseDelete(SERVICE);
	}

	public void getObjById() {
		this.print(JsonUtil.obj2Json(this.getObject(SERVICE)));
	}
}
